package com.syg.listener;

import com.syg.event.LoanSuccessEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author syg
 */
@Component
// public class LoanListener implements ApplicationListener<ApplicationEvent> {
public class LoanListener {

    Logger log = LoggerFactory.getLogger(LoanListener.class);

    @EventListener(classes = LoanSuccessEvent.class)
    public void onSuccess(LoanSuccessEvent event) {
        System.out.println("监听成功了");
        log.info("LoanSuccessEvent={}", event);
    }

    // /**
    //  * 这是一种错误写法,导致监听多次
    //  * https://blog.csdn.net/zxd1435513775/article/details/121241025
    //  * @param event
    //  */
    // @Override
    // public void onApplicationEvent(ApplicationEvent event) {
    //     System.out.println("12333333");
    // }
}
